package com.ww.gateway.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

@Component
public class TestFilter implements GlobalFilter, Ordered {
    private static final Logger LOG = LoggerFactory.getLogger(TestFilter.class);
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        LOG.info("------------------TestFilter -------------------");
        // 因为是mono返回类型，需要chain链路，这里代表执行下一个过滤器
        return chain.filter(exchange);
    }

    @Override
    public int getOrder() {
        return 100;
    }
}
